#example one

import collections

def default_factory():
    return 'default value'

d = collections.defaultdict(default_factory)
d['foo'] = 'bar'

#exist
print 'foo =>', d['foo']
#not exist
print 'bar =>', d['bar']

#exampe two - default return list object
dictionary = collections.defaultdict(list)

dictionary['foo'].append(1)
print dictionary['foo']

print dictionary['bar']




